﻿using UnityEngine;

public class DirtSicknessBehaviour : SicknessBehaviour
{
    [SerializeField] ParticleSystem sicknessParticleSystem;
    [SerializeField] Material sicknessMaterial;

    public override void Activate(AnimalBehaviour animalBehaviour)
    {
        base.Activate(animalBehaviour);

        // Get skinned mesh renderer and activate material
        animalBehaviour.SetMaterial(sicknessMaterial);

        // Activate particle
        sicknessParticleSystem.Play();
    }

    public override void DisableSickness()
    {
        // Play sickness particle
        ParticlesController.PlayParticle(animalBehaviour.ActiveSickness.ParticleHash).SetPosition(transform.position);

        animalBehaviour.ResetMaterial();

        // Stop particle
        sicknessParticleSystem.Stop();

        // Return sickness behaviour to pool
        transform.SetParent(null);
        gameObject.SetActive(false);

        animalBehaviour = null;
    }
}